<?php 

class ContentScopeCondition extends AppModel
{
	var $name = 'ContentScopeCondition';
	
	var $useTable = false;
	
	var $fieldProperties = array(
	
		'field' => array(
			'type' => 'select',
			'group' => 'add',
			'empty' => '-Select-',
			'class'=> 'contentScopeConditionField',
			'triggers' => array('onChange' => array('update' => 'value')),
			'options' => array('list_category_id' => 'Category', 'is_featured' => 'Featured', 'is_editorial' => 'Editorial')
		),
		'value' => array(
			'type' => 'select',
			'group' => 'add'
		)
	);
	
	
	function getValueOptions($field)
	{
		$options = array(__('False'), __('True'));
		if($field == 'list_category_id')
		{
			//trick to for merging string in numeric keys
			$categories = cri('ListCategory')->getOptions();
			$options =  array_combine(am(array('autodetect'),array_keys($categories)),am(array(__('Autodetect')),$categories));
		}
		return $options;
	}
	
	function initialize()
	{		
		$editorReviewDisabled = cr('GeneralConfig.disable_editor_reviews');
		if($editorReviewDisabled)
		{
			unset($this->fieldProperties['field']['options']['is_editorial']);
		}
		parent::initialize();
		
	}
	
	function afterInitialize()
    {
    	$fieldProperties = $this->fieldProperties;
    	foreach($fieldProperties as $field=>$properties)
    	{
    		if(isset($properties['options']))
    		{
	    		foreach($properties['options'] as $value=>$label)
	    		{
	    			$newOptionList[$value] = __($label).'____';
	    		}
    			if(isset($properties['empty']))
	    		{
	    			$this->fieldProperties[$field]['empty'] = __($properties['empty']);
	    		}
	    		$this->fieldProperties[$field]['options'] = $newOptionList;
	    	}
	    	$newOptionList = array();
	    } 
    	parent::afterInitialize();	
    }
}

?>